package com.moli.iov.his.service.impl;

import com.moli.iov.his.mapper.ReportStoreTotalOnlineMapper;
import com.moli.iov.his.model.po.ReportStoreTotalOnline;
import com.moli.iov.his.model.po.ReportTotalOnline;
import com.moli.iov.his.service.IReportStoreTotalOnlineService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.moli.iov.his.util.HisUtil;
import com.moli.iov.rest.RestResponse;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 门店、中转库全网在线车辆统计 服务实现类
 * </p>
 *
 * @author lxy
 * @since 2019-06-17
 */
@Service("reportStoreTotalOnlineService")
public class ReportStoreTotalOnlineServiceImpl extends ServiceImpl<ReportStoreTotalOnlineMapper, ReportStoreTotalOnline> implements IReportStoreTotalOnlineService {

    @Resource
    private ReportStoreTotalOnlineMapper reportStoreTotalOnlineMapper;
    @Override
    public RestResponse saveReportTotalOnline(ReportStoreTotalOnline reportStoreTotalOnline) {
        boolean save = save(reportStoreTotalOnline);
        return save ? RestResponse.success() : RestResponse.failure("新增在网车辆统计失败！");
    }

    @Override
    public List<ReportStoreTotalOnline> queryOnlineReport(String storeCode) throws Exception {
        List<ReportStoreTotalOnline> reportTotalOnlines = reportStoreTotalOnlineMapper.queryOnlineReport(storeCode);
        List<ReportStoreTotalOnline> ret = HisUtil.getStoreOnlineDateReport(reportTotalOnlines);
        return ret;
    }

    @Override
    public List<ReportStoreTotalOnline> queryOnlineReportByTime(Map map) throws Exception {
        return reportStoreTotalOnlineMapper.queryOnlineReportByTime(map);
    }
}
